package pcsr.drivers.nxtDriver;

enum NXTSensorMode {
	RAW( 0 ), 
	BOOLEAN( 1 ), 
	TRANSITIONCOUNTER( 2 ), 
	PERIODCOUNTER( 3 ), 
	PCTFULLSCALE( 4 ), 
	CELSIUS( 5 ), 
	FAHRENHEIT( 6 ), 
	ANGLESTEPS( 7 ), 
	SLOPEMASK( 8 ), 
	MODEMASK( 9 );
	
	private int sensorMode;
	
	private NXTSensorMode( int value )
	{
		if(value < 0 || value > 9)
		{
			throw new IllegalArgumentException("NXTSensorMode values between 0 and 9.");
		}
		sensorMode = value;
	}
	
	public int GetModeValue( )
	{
		return sensorMode;
	}
	
	public static NXTSensorMode GetModeByValue( final int value )
	{
		switch (value) 
		{
			case 0:
				return RAW;
			case 1:
				return BOOLEAN;
			case 2:
				return TRANSITIONCOUNTER;
			case 3:
				return PERIODCOUNTER;
			case 4:
				return PCTFULLSCALE;
			case 5:
				return CELSIUS;
			case 6:
				return FAHRENHEIT;
			case 7:
				return ANGLESTEPS;
			case 8:
				return SLOPEMASK;
			case 9:
				return MODEMASK;
		}
		return null;
	}
	
	
}
